import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Scanner;

public class Test {

    public static int function(){
        Scanner scanner=new Scanner(System.in);
        try {
            int x = scanner.nextInt();
            return x;
        }catch (InputMismatchException e){
            e.printStackTrace();
            System.out.println("输入错误");
        }finally {
            return -1;
        }

    }

    public static void main(String[] args) {
        System.out.println(function());
    }

    public static void main11(String[] args) {
        Scanner scanner = new Scanner(System.in);
        try {
            int a =scanner.nextInt();
            System.out.println(a);
        }catch (InputMismatchException e){
            e.printStackTrace();
            System.out.println("数据存在问题");
        }
        finally {
            scanner.close();
        }
    }

    public static void main7(String[] args) {
        try {
            int[] array = {1, 2, 3};
            System.out.println(array[1]);
            System.out.println("hello");
        } catch (ArrayIndexOutOfBoundsException e) {
            e.printStackTrace();
            System.out.println("数组越界异常");
        } catch (NullPointerException e) {
            e.printStackTrace();
            System.out.println("空指针异常");
        } catch (RuntimeException e) {
            e.printStackTrace();
            System.out.println("运行异常");
        } finally {
            System.out.println("Finnal执行");
        }

        System.out.println("程序执行");
    }


    public static void func(int[] array) throws CloneNotSupportedException {
        if (array == null) {
            throw new CloneNotSupportedException();
        }
        System.out.println("array not null");
    }

    public static void main6(String[] args) {
        try {
            func(null);
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
            System.out.println("捕捉了 CloneNotSupportedException");
        }
        System.out.println("hahaha");
    }


    public static void rtmaintr6(String[] args) throws CloneNotSupportedException,
            NullPointerException {
        func(null);
        System.out.println("hahaha");
    }


    /*public static void main(String[] args) {

    }*/

    public static int getElement(int[] array, int index) {
        if (null == array) {
            throw new NullPointerException("传递的数组为null");
        }
        if (index < 0 || index >= array.length) {
            throw new ArrayIndexOutOfBoundsException("传递的数组下标越界");
        }
        return array[index];
    }

    public static void main4(String[] args) {
        //int[] array = {1, 2, 3};
        int[] array = null;
        getElement(array, 3);
    }

    public static void main3(String[] args) {
        /*int[] arr = null;
        System.out.println(arr.length);*/

        int[] arr = {1, 2, 3};
        System.out.println(arr[100]);
    }

    public static void main2(String[] args) {
        int[] array = {10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
        Arrays.sort(array);
        int mid = Arrays.binarySearch(array, 5);
        System.out.println(mid);
    }


    public static void main1(String[] args) {
        int x;
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextInt()) {
            System.out.println();
        }
        scanner.close();
        /*String name = scanner.nextLine();
        x=scanner.nextInt();
        System.out.println(name);
        System.out.println(x);*/


    }
}
